#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i ++) {
    cin >> a[i];
  }
  vector<int> diff(n + 2);
  for (int i = n; i >= 1; i --) {
    diff[i] = a[i] - a[i - 1];
  }
  while (m --) {
    int l, r, add;
    cin >> l >> r >> add;
    diff[l] += add;
    diff[r + 1] -= add;
  }
  for (int i = 1; i <= n; i ++) {
    a[i] = a[i - 1] + diff[i];
  }
  cout << *min_element(a.begin() + 1, a.end()) << endl;
}